# ./selfcheck.py -- The file for security checks.
#coding:utf-8

# Import Needs
import inspect
from constants import *


# Self Check Function
def selfcheck(loggerset):
    """
    documentation of fuction security.selfcheck()
    ---------------------------------------------
    A self check function.
    ---------------------------------------------
    loggerset: the logger set you're using.
    """
    loggerset.log("Starting Self Check.", ln=inspect.getframeinfo(inspect.currentframe()).lineno, filename=__file__)
    # Module Import Test
    try:
        # Remember to update when new modules join in!
        loggerset.log("Try to import GUI startpoint...", ln=inspect.getframeinfo(inspect.currentframe()).lineno, filename=__file__)
        from utils.gui import startgui    # Try to load GUI startpoint.
        return startgui

    except Exception as e:  # If error occurs...
        loggerset.log(e, level=ERROR, ln=inspect.getframeinfo(inspect.currentframe()).lineno, filename=__file__)   # Print out errors. 
        loggerset.log("Can't import GUI startpoint.", level=ERROR, ln=inspect.getframeinfo(inspect.currentframe()).lineno, filename=__file__)
        try:
            loggerset.log("Try to import console startpoint...", ln=inspect.getframeinfo(inspect.currentframe()).lineno, filename=__file__)
            from utils.console import start
            return start

        except Exception as e:
            loggerset.log(e, level=ERROR, ln=inspect.getframeinfo(inspect.currentframe()).lineno, filename=__file__)    # Print out errors.
            loggerset.log("Can't import console startpoint.", level=ERROR, ln=inspect.getframeinfo(inspect.currentframe()).lineno, filename=__file__)
            loggerset.log("Importation Self Check Failed!", level=FATAL, ln=inspect.getframeinfo(inspect.currentframe()).lineno, filename=__file__)
            raise